package gameAppLayer.stateMachine.strategyState;

import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import universe.UniverseBuilder;

import com.jme3.asset.AssetKey;
import com.jme3.asset.AssetManager;
import com.jme3.input.InputManager;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;

import controller.AbstractController;
import controller.IController;
import controls.IMasterControl;

import eventManager.EventManager;
import gameAppLayer.GameSettings;
import gameAppLayer.XMLData;
import gameAppLayer.ExternalData;
import gameAppLayer.stateMachine.GameState;

/*
 * A factory that creates the Strategy GameState
 */
public class StrategyStateBuilder {
	
	private static final Logger logger = Logger.getLogger(StrategyStateBuilder.class.getName());
	
	public StrategyStateBuilder() {
		
	}
	
	@SuppressWarnings("rawtypes")
	public GameState createGameState(
			GameSettings settings, 
			InputManager inputManager, 
			Camera cam,			 
			ExternalData externalData) {
		
		logger.log(Level.INFO, "createGameState() entered");
		//QQQ:  May have to pass externalData and/or assetMap to the state...?
		StrategyState gameState = new StrategyState(inputManager, cam);
		
		/*
		 * Add relevant controllers.  Attach their models, views as needed
		 */				
		UniverseBuilder universeFact = new UniverseBuilder(settings, externalData);
		gameState.masterControls = universeFact.createUniverse();
		
		logger.log(Level.INFO, "createGameState() Universe created");
		
		for (IMasterControl controller: gameState.masterControls) {
			gameState.masterControlMap.put(controller.getKey(), controller);
		}
		
		logger.log(Level.INFO, "createGameState() Controllers mapped to " + gameState.getGameStateID());
		
		return gameState;
	}

}
